﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Prism.Events;
using YF_Music.Core.Extensions;
using YF_Music.Modules.APP_My.Events;

namespace YF_Music.Modules.APP_My.Views
{
  /// <summary>
  /// PlayMusicView.xaml 的交互逻辑
  /// </summary>
  public partial class PlayMusicView : UserControl
  {
    private readonly IEventAggregator eventAggregator;

    public PlayMusicView(IEventAggregator eventAggregator)
    {
      InitializeComponent();
      this.eventAggregator = eventAggregator;
      this.eventAggregator.GetEvent<ScrollToCenterOfViewEvent>()
        .Subscribe(OnScrollToCenterOfView, ThreadOption.UIThread);
    }

    private void OnScrollToCenterOfView(int index)
    {
      LyricsListBox.ScrollToCenterOfView(LyricsListBox.Items[index]);
    }
  }
}
